﻿#pragma once
#include "Hazel.h"
#include <Log.h>
#include "ExampleLayer.h"
#include "Renderer/Camera.h"
#include "Renderer/Renderer.h"
#include "Renderer/Buffer.h"

class SandboxApp : public Hazel::Application
{
public:
    SandboxApp()
    {
        HZ_INFO("SandboxApp Created!");
        PushLayer(new ExampleLayer());
    }

    ~SandboxApp()
    {
        HZ_INFO("SandboxApp Destroyed!");
    }
    void SandboxApp::OnEvent(Hazel::Event &e) override
    {
        std::stringstream ss;
        ss << e.ToString();
        HZ_INFO(ss.str());

        Hazel::EventDispatcher dispatcher(e);
        dispatcher.Dispatch<Hazel::WindowCloseEvent>(HZ_BIND_EVENT_FN(SandboxApp::OnWindowClose));
        dispatcher.Dispatch<Hazel::WindowResizeEvent>(HZ_BIND_EVENT_FN(SandboxApp::OnWindowResize));
    }

    bool OnWindowClose(Hazel::WindowCloseEvent &e)
    {
        return true;
    }

    bool OnWindowResize(Hazel::WindowResizeEvent &e)
    {
        // Handle resize
        return false;
    }
    void SandboxApp::OnUpdate()
    {
        Hazel::Renderer::BeginScene(m_Camera);
        Hazel::Renderer::Submit(m_VertexArray);
        // Hazel::Renderer::EndScene();
    }

private:
    Hazel::Camera m_Camera;
    Hazel::Ref<Hazel::VertexArray> m_VertexArray;
};